
#include "stdio.h"
#include "iostream"
#include "f_extern.h"

using namespace std;

int main(int argc, char* argv[])
{
	
	char* _f_ = "[format]";
	FILE* config = NULL; 
	FILE* block = NULL;
	
	int num;
	string file_name;
	header dir;
	
		dir.type = 0;
		dir.size = 0;
		dir.last_time = 0;
	if(argc<2){
		return 1;
	}
	else if (argc >2){
#ifdef PRINT_MSG 
		printf("%s: Use  format root\n",_f_); 
#endif
		return 2;
		}
	
		file_name = argv[1];
		file_name.append("./.1");
		
		block = fopen(file_name.data(),"rb+");
		if(block == NULL)
		{
#ifdef PRINT_MSG 
			printf("%s: Can't open superblock file.\n",_f_); 
#endif
			return 4;
		}
		else
		{
			fseek(block,sizeof(int),SEEK_SET);
			fread(&block_size,sizeof(int),1,block);
			fread(&block_num,sizeof(int),1,block);

			fseek(block,0,SEEK_SET);
			dir.data_block = 2;
			fwrite(&dir,sizeof(header),1,block);

			num = block_size;
			fwrite(&num,sizeof(int),1,block);
			num = block_num;
			fwrite(&num,sizeof(int),1,block);
			fclose(block);

		}
		
	return 0;

}

